//
//  String + Extension.swift
//  COPYCAT-Weibo
//
//  Created by 闫萌 on 1/5/16.
//  Copyright © 2016 RendezvousAuParadis. All rights reserved.
//

import Foundation

extension NSMutableAttributedString {
//            attrText.setAttributes([NSForegroundColorAttributeName : UIColor.lightGrayColor(), NSFontAttributeName : UIFont.systemFontOfSize(12)], range: contentString.rangeOfString(useName))
    
    ///  为属性字符串的其中一部分设置属性，默认文字颜色为深灰色
    ///
    ///  - parameter substring: <#substring description#>
    ///  - parameter fontSize:  <#fontSize description#>
    ///  - parameter textColor: <#textColor description#>
    func setAttributesForSubstring(substring: String, fontSize: CGFloat, textColor: UIColor = UIColor.darkGrayColor()) {
        self.addAttributes([NSFontAttributeName : UIFont.systemFontOfSize(fontSize), NSForegroundColorAttributeName : textColor], range: (self.string as NSString).rangeOfString(substring))
    }
    
}

